<?php
/*
 * Evaluation
 * By Hylson, Helton and Jackson
 * Rio do Sul - Santa Catarina - BRASIL
 */
 
//This page prints a particular instance of evaluation

    require_once("../../config.php");
    require_once("lib.php");
 
/// Useful to get information about current user and course
    require_once($CFG->dirroot.'/user/profile/lib.php');

?>

<?php

    $id = optional_param('id', 0, PARAM_INT); // Course Module ID, or
    $a  = optional_param('a', 0, PARAM_INT);  // evaluation ID

    if ($id) {
        if (! $cm = get_record("course_modules", "id", $id)) {
            error("Course Module ID was incorrect");
        }

        if (! $course = get_record("course", "id", $cm->course)) {
            error("Course is misconfigured");
        }

        if (! $evaluation = get_record("evaluation", "id", $cm->instance)) {
            error("Course module is incorrect");
        }

    } else {
        if (! $evaluation = get_record("evaluation", "id", $a)) {
            error("Course module is incorrect");
        }
        if (! $course = get_record("course", "id", $evaluation->course)) {
            error("Course is misconfigured");
        }
        if (! $cm = get_coursemodule_from_instance("evaluation", $evaluation->id, $course->id)) {
            error("Course Module ID was incorrect");
        }
    }

    require_login($course->id);

    add_to_log($course->id, "evaluation", "view", "view.php?id=$cm->id", "$evaluation->id");

/// Print the page header
    $strevaluations = get_string("modulenameplural", "evaluation");
    $strevaluation  = get_string("modulename", "evaluation");
		
    print_header_simple(format_string($evaluation->name), "",
            "<a href=\"index.php?id=".$course->id."\">$strevaluations</a> -> " . format_string($evaluation->name),"", "", true,
            update_module_button($cm->id, $course->id, $strevaluation), navmenu($course, $cm));

?>

<hr/>

<?php
    /// Print the main part of the page 
	
    print_box($evaluation->description." (<a href=view_history.php?id=".$cm->id.">".get_string("see_history", "evaluation")."</a>)", 'generalbox', 'intro');

    print_box(evaluation_show_form($cm->id), 'generalbox','intro');

?>

<?php
/// Finish the page
    print_footer($course);
?>
